#include "Key.h"

Key::Key(sf::Keyboard::Key aKey) : key(aKey), pressed(false), tapped(false) {
}

Key::~Key() {
}

void Key::update() {
    if(sf::Keyboard::isKeyPressed(key)) {
        if(!pressed) {
            tapped = true;
            pressed = true;
        } else if(pressed) {
            tapped = false;
        }
    } else {
        tapped = false;
        pressed = false;
    }
}

void Key::setKey(sf::Keyboard::Key aKey) {
    key = aKey;
}

bool Key::isPressed() {
    return pressed;
}

bool Key::isTapped() {
    return tapped;
}
